package com.ityedao.数组;

public class BasicPractice7 {
    public static void main(String[] args) {
        /**
         * 小李用自己的钱买了十只股票，
         * 年末他看了各只股票的收益分别是
         * 10.4%,-3%,-6.2%,1.2%,-6.1%,-19%,-3.8%,0.9%,-4.5%,5.5%。
         * 请使用数组相关知识编程，帮他统计赚钱的股票和赔钱的股票分别有多少只？
         */
        double[] stocks =  {10.4, -3,-6.2, 1.2, -6.1, -19, -3.8, 0.9, -4.5, 5.5};
        int profitableStockNum = 0;
        int unprofitableStockNum = 0;
        for (int i = 0; i < stocks.length; i++) {
            if (stocks[i] > 0){
                profitableStockNum ++;
            }else {
                unprofitableStockNum ++;
            }
        }
        System.out.println("赚钱的股票共有：" + profitableStockNum + "只");
        System.out.println("不赚钱的股票共有：" + unprofitableStockNum + "只");
    }
}
